package ar.edu.unicen.pladema.ui.panel.options;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import ar.edu.unicen.pladema.main.SWTUtils;
import ar.edu.unicen.pladema.resources.ResourceManager;
import ar.edu.unicen.pladema.ui.model.ColorRange;
import ar.edu.unicen.pladema.ui.mywidgets.ColorList;
import ar.edu.unicen.pladema.ui.mywidgets.IterationPanel;
import ar.edu.unicen.pladema.vc1.model.GraphicAttributes;
import ar.edu.unicen.pladema.vc1.practico.PanelOption;

public class POP2E3 extends PanelOption {
	private Label last;
	private ColorList colorList;
	private IterationPanel iterationPanel;

	public POP2E3(Composite parent, IPaintIt pi, GraphicAttributes ga) {
		super(parent, pi, ga);
	}

	@Override
	protected void createWidgetsImpl() {
		last = new Label(this, SWT.NONE);
		colorList = new ColorList(this);
		iterationPanel = new IterationPanel(this);
	}

	@Override
	protected FormData layoutWidgets(FormData fd) {
		last.setLayoutData(fd);
		iterationPanel.setLayoutData(SWTUtils.createBelowFormData(last,5));
		colorList.setLayoutData(SWTUtils.createBelowFormData(iterationPanel,5));
		return SWTUtils.createBelowFormData(colorList,5);
	}

	@Override
	protected void loadGraphicData() {
		last.setText(ResourceManager.getInstance().getText(graphicAttributes.get(GraphicAttributes.LAST_ACTION)));
		iterationPanel.setValue(graphicAttributes.getInt(GraphicAttributes.MAX_ITERATIONS));
	}

	@Override
	protected void saveGraphicData() {
		graphicAttributes.add(GraphicAttributes.MAX_ITERATIONS, iterationPanel.getValue());
	}

	public ColorRange getColorRange() {
		return colorList.getColorRange();
	}
	public void setColorRange(ColorRange colorRange) {
		this.colorList.setColorRange(colorRange);
	}
	
}
